Transpose of a matrix in 2d array